package com.office.dates.server.impl;

import com.office.common.utils.SecurityUtils;
import com.office.dates.domain.Dates;
import com.office.dates.mapper.DatesMapper;
import com.office.dates.server.DatesServer;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 柒月
 * @date: 2025/6/26 下午3:42
 * @version: 1.0
 */
@Service
public class DatesServerImpl implements DatesServer {

    @Resource
    private DatesMapper datesMapper;

    @Override
    public List<Dates> getDatesToDay(String today) {
        Long loginUserId = SecurityUtils.getUserId();
        return datesMapper.selectDatesToDay(today, loginUserId);
    }

    @Override
    public void addDate(Dates dates) {
        Long loginUserId = SecurityUtils.getUserId();
        dates.setUserId(loginUserId);
        datesMapper.installDate(dates);
    }

    /**
     * @return 获取全部的日程信息
     */
    @Override
    public List<Dates> getDatesAll() {
        // 获取全部的日程信息
        Long loginUserId = SecurityUtils.getUserId();
        return datesMapper.selectDatesAll(loginUserId);
    }

    /**
     * @return 今天的日程
     */
    @Override
    public List<Dates> getDatesToTheDay() {
        // 获取登录用户id
        Long loginUserId = SecurityUtils.getUserId();
        return datesMapper.selectDatesToTheDay(loginUserId);
    }

    /**
     *
     * @return 获取会议数和总数
     */
    @Override
    public Dates getDateCount() {
        // 获取当前登录用户
        Long loginUserId = SecurityUtils.getUserId();
        return datesMapper.selectDateConut(loginUserId);
    }
}
